<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport"/>
    <title></title>
    <meta content="" name="keywords"/>
    <meta content="" name="description"/>
    <link href="/web/css/normalize.css" rel="stylesheet" type="text/css"/>
    <link href="/web/css/style.css" rel="stylesheet" type="text/css"/>
    <link href="/web/css/animate.css" rel="stylesheet" type="text/css"/>
    <link href="/web/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
    <link href="/web/layui/css/layui.css" rel="stylesheet" type="text/css"/>
    <style>
        [v-cloak] {
            display: none;
        }
    </style>
</head>
<body>
<div id="app" v-cloak>
    <div class="contain">
        <div class="sidebar" id="head"></div>
        <section>
            <div class="right_h" id="right_h">

            </div>
            <div class="qulicklink">
                <ul>
                    <li><a href="javascript:;"></a></li>
                    <li><a href="javascript:;"><span>企业首页</span><img src="/web/images/close.png"></a></li>
                    <li class="dq"><a href="javascript:;"><span>业务管理</span><img src="/web/images/close.png"></a></li>
                    <li><a href="javascript:;"></a></li>
                </ul>
            </div>
            <div class="breadcrumbs">
                <ul>
                    <li><a href="">系统设置</a></li>
                    <li>部门列表</li>
                </ul>
            </div>
            <div class="clearfix"></div>
            <div class="content">
                <div class="addbtn" v-if="sum(24)">
                    <a @click="addbtnClick()" href="javascript:;">新增</a>
                </div>
                <div class="deletebtn" v-if="sum(26)">
                    <a @click="deletesClick()" href="javascript:;">删除</a>
                </div>
                <div class="importbtn" v-if="sum(27)">
                    <a @click="importClick()" href="javascript:;">导入</a>
                </div>
                <div class="adSearchbtn">
                    <a @click="adSearchbtnClick()" href="javascript:;">高级搜索</a>
                </div>
                <!--高级搜索下拉框开始-->
                <div class="searchBox">
                    <div class="searchKey">
                        <label>
                            <span>客户名称:</span> <input autocomplete="off" id="searchtitle" name="resetval"
                                                      placeholder="请输入客户名称"
                                                      type="text"/>
                        </label>
                        <label>
                            <span>客户类型:</span>
                            <div class="layui-input-block">
                                <select autocomplete="off" id="searchtype" lay-filter="batch"
                                        lay-search="required" lay-verify="required" name="resetval">
                                    <option class="promptColor" value="0">请选择客户类型</option>
                                    <option :value="v.id" v-for="(v,k) in ajaxData.type">{{v.title}}</option>
                                </select>
                            </div>
                        </label>
                        <label>
                            <span>客户状态:</span>
                            <div class="layui-input-block">
                                <select class="industry" id="searchstatus" lay-filter="batch"
                                        lay-search="required" lay-verify="required" name="resetval">
                                    <option class="promptColor" value="0">请选择客户状态</option>
                                    <option value="1">有效客户</option>
                                    <option value="2">无效客户</option>
                                </select>
                            </div>
                        </label>
                        <label>
                            <span>所属行业:</span>
                            <div class="layui-input-block">
                                <select id="searchindustry" lay-filter="batch" lay-search="required"
                                        lay-verify="required" name="resetval">
                                    <option class="promptColor" value="0">请选择所属行业</option>
                                    <option :value="v.id" v-for="(v,k) in ajaxData.industry">{{v.title}}</option>
                                </select>
                            </div>
                        </label>
                        <label>
                            <span>所属地区:</span>
                            <div class="layui-input-block">
                                <select id="searchprovince" lay-filter="batch" lay-search="required"
                                        lay-verify="required" name="resetval">
                                    <option class="promptColor" value="0">请选择所属地区</option>
                                    <option :value="v.id" v-for="(v,k) in ajaxData.province">{{v.name}}</option>
                                </select>
                            </div>
                        </label>
                        <label>
                            <span>客户级别:</span>
                            <div class="layui-input-block">
                                <select autocomplete="off" class="category" id="categoryid"
                                        lay-filter="batch" lay-search="required" lay-verify="required" name="resetval">
                                    <option class="promptColor" value="0">请选择客户级别</option>
                                    <option :value="v.id" v-for="(v,k) in ajaxData.category">{{v.title}}</option>
                                </select>
                            </div>
                        </label>
                        <label>
                            <span>电话号码:</span> <input class="username" id="searchtel" name="resetval"
                                                      placeholder="请输入客户电话号码" type="text"/>
                        </label>
                        <label>
                            <span>客户来源:</span>
                            <div class="layui-input-block">
                                <select id="searchfrom" lay-filter="batch" lay-search="required"
                                        lay-verify="required" name="resetval">
                                    <option class="promptColor" value="0">请选择客户来源</option>
                                    <option :value="v.id" v-for="(v,k) in ajaxData.from">{{v.title}}</option>
                                </select>
                            </div>
                        </label>
                        <label>
                            <span>业务员:</span>
                            <div class="layui-input-block">
                                <select id="searchuser" lay-filter="batch" lay-search="required"
                                        lay-verify="required" name="resetval">
                                    <option class="promptColor" value="0">请选择业务员</option>
                                    <option :value="v.id" v-for="(v,k) in ajaxData.user">{{v.realname}}</option>
                                </select>
                            </div>
                        </label>
                    </div>
                    <div class="btns">
                        <div class="addbtn searchbtn">
                            <a @click="searchbtnClick()" href="javascript:;">搜索</a>
                        </div>
                        <div class="addbtn setbtn">
                            <a @click="resetbtnClick()" href="javascript:;">重置</a>
                        </div>
                    </div>
                </div>
                <!--高级搜索下拉框结束-->

                <!-- 这里是新增编辑弹出框开始-->
                <div class="consulting hidden">
                    <div class="addtitle">基本信息</div>
                    <div class="layerbody">
                        <label>
                            <span>客户名称:</span> <input autocomplete="off" class="username" id="title" name="resetTc"
                                                      placeholder="请输入客户名称" type="text"/>
                        </label>
                        <label>
                            <span>网址:</span> <input autocomplete="off" class="link" id="link" name="resetTc"
                                                    placeholder="请输入客户网址" type="text"/>
                        </label>
                        <label>
                            <span>联系人:</span> <input autocomplete="off" class="contacts" id="contacts" name="resetTc"
                                                     placeholder="请输入联系人" type="text"/>
                        </label>
                        <label>
                            <span>电话号码:</span> <input autocomplete="off" class="tel" id="tel" maxlength="11"
                                                      name="resetTc" placeholder="请输入电话号码" type="text"/>
                        </label>
                        <div class="address1">
                            <label>
                                <span>省份:</span>
                                <div class="layui-input-block">
                                    <select @change="provincechange($event)" autocomplete="off" id="provinceid"
                                            lay-filter="batch" lay-search="required" lay-verify="required"
                                            name="resetTc" v-model="provinceid">
                                        <option class="promptColor" value="0">请选择所在省份</option>
                                        <option :value="v.id" v-for="(v,k) in ajaxData.province">{{v.name}}</option>
                                    </select>
                                </div>
                            </label>
                            <label>
                                <span>城市:</span>
                                <div class="layui-input-block">
                                    <select autocomplete="off" id="cityid" lay-filter="batch"
                                            lay-search="required" lay-verify="required" name="resetTc" v-model="cityid">
                                        <option class="promptColor" value="0">请选择所在市区</option>
                                        <option :value="v.id" v-for="(v,k) in ajaxData.city">{{v.name}}</option>
                                    </select>
                                </div>
                            </label>
                        </div>
                        <div class="address">
                            <label>
                                <span>地址:</span> <input autocomplete="off" class="address" id="address" name="resetTc"
                                                        placeholder="请输入客户地址" type="text"/>
                            </label>
                        </div>
                        <label>
                            <span>客户类型:</span>
                            <div class="layui-input-block">
                                <select autocomplete="off" class="type" id="typeid"
                                        lay-filter="batch" lay-search="required" lay-verify="required" name="resetTc"
                                        v-model="typeid">
                                    <option class="promptColor" value="0">请选择客户类型</option>
                                    <option :value="v.id" v-for="(v,k) in ajaxData.type">{{v.title}}</option>
                                </select>
                            </div>
                        </label>
                        <label>
                            <span>客户级别:</span>
                            <div class="layui-input-block">
                                <select autocomplete="off" class="category" id="categoryid"
                                        lay-filter="batch" lay-search="required" lay-verify="required" name="resetTc"
                                        v-model="categoryid">
                                    <option class="promptColor" value="0">请选择客户级别</option>
                                    <option :value="v.id" v-for="(v,k) in ajaxData.category">{{v.title}}</option>
                                </select>
                            </div>
                        </label>
                        <label>
                            <span>来源:</span>
                            <div class="layui-input-block">
                                <select autocomplete="off" class="from" id="fromid"
                                        lay-filter="batch" lay-search="required" lay-verify="required" name="resetTc"
                                        v-model="fromid">
                                    <option class="promptColor" value="0">请选择客户来源</option>
                                    <option :value="v.id" v-for="(v,k) in ajaxData.from">{{v.title}}</option>
                                </select>
                            </div>
                        </label>
                        <label>
                            <span>行业:</span>
                            <div class="layui-input-block">
                                <select autocomplete="off" class="industry" id="industryid"
                                        lay-filter="batch" lay-search="required" lay-verify="required" name="resetTc"
                                        v-model="industryid">
                                    <option class="promptColor" value="0">请选择行业</option>
                                    <option :value="v.id" v-for="(v,k) in ajaxData.industry">{{v.title}}</option>
                                </select>
                            </div>
                        </label>
                        <label>
                            <span>咨询日期:</span>
                            <div class="layui-input-inline">
                                <input autocomplete="off" class="layui-input" id="date3" name="resetTc"
                                       placeholder="yyyy-MM-dd" type="text">
                            </div>
                        </label>
                        <div class="address">
                            <label>
                                <span>描述:</span>
                                <textarea autocomplete="off" class="contents" id="content" name="resetTc"
                                          placeholder="您的留言"
                                          resize="" rows="4"></textarea>
                            </label>
                        </div>
                        <label v-if="sum(70)">
                            <span>分配人:</span>
                            <div class="layui-input-block">
                                <select autocomplete="off" class="industry" id="userid"
                                        lay-filter="batch" lay-search="required" lay-verify="required" name="resetTc"
                                        v-model="userid">
                                    <option class="promptColor" value="0">请选择分配人</option>
                                    <option :value="v.id" v-for="(v,k) in ajaxData.user">{{v.realname}}</option>
                                </select>
                            </div>
                        </label>
                        <label>
                            <span>客户状态:</span>
                            <div class="layui-input-block">
                                <select class="industry" id="status" lay-filter="batch"
                                        lay-search="required" lay-verify="required" name="resetTc" v-model="status">
                                    <option class="promptColor" value="1" selected>有效客户</option>
                                    <option value="2">无效客户</option>
                                </select>
                            </div>
                        </label>

                    </div>
                    <button @click="addeditsureBtn()" class="surebtn" type="submit">确认</button>
                    <button @click="addresetBtn()" class="resetbtn" type="submit">重置</button>
                </div>
                <!-- 这里是新增编辑弹出框结束-->
                <div class="search">
                    <!--模糊查询开始-->
                    <label>
                        <span>搜索:</span>
                        <div class="searchbox">
                            <input @input="search($event)" placeholder="请输入您要搜索关键字" type="text">
                        </div>
                    </label>
                    <!--模糊查询结束-->

                </div>
            </div>
            <div class="t_body">
                <div class="table-responsive">
                    <table class="table">
                        <thead>
                        <tr>
                            <th><input @click="deleteCheckAll()" class="checkboxAll" id="deleteCheckAll"
                                       type="checkbox"> 全选
                            </th>
                            <th>客户名称</th>
                            <th>电话</th>
                            <th>客户类型</th>
                            <th>客户级别</th>
                            <th>客户来源</th>
                            <th>省份</th>
<!--                            <th>城市</th>-->
                            <th>所属行业</th>
                            <th>员工</th>
<!--                            <th>部门</th>-->
<!--                            <th>创建时间</th>-->
                            <th>客户状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr @dblclick="editorClick(v.id)" v-for="(v,index) in tableDataList">
                            <td><input :id="'listcheck' + (v.id)" class="selectCheck" type="checkbox"></td>
                            <td>{{v.title}}</td>
                            <td>{{v.tel}}</td>
                            <td>{{v.typetitle}}</td>
                            <td>{{v.categorytitle}}</td>
                            <td>{{v.fromtitle}}</td>
                            <td>{{v.provincename}}</td>
<!--                            <td>{{v.cityname}}</td>-->
                            <td>{{v.industrytitle}}</td>
                            <td>{{v.username}}</td>
<!--                            <td>{{v.charactertitle}}</td>-->
<!--                            <td>{{v.createtime}}</td>-->
                            <td style="color: #f00" v-if="v.status == 2">无效</td>
                            <td style="color: #31c37a" v-else>有效</td>
                            <td>
                                <div class="returnvisit" v-if="sum(29)">
                                    <a @click="visitClick(v.id)" href="javascript:;">
                                        <img src="images/visit.jpg">
                                    </a>
                                    <span>回访</span>
                                </div>
                                <div class="view" v-if="sum(28)">
                                    <a @click="viewClick(v.id)" href="javascript:;">
                                        <img src="images/view.png">
                                    </a>
                                    <span>查看</span>
                                </div>
                                <div class="editor" v-if="sum(25)">
                                    <a @click="editorClick(v.id)" href="javascript:;">
                                        <img src="images/editor.png">
                                    </a>
                                    <span>编辑</span>
                                </div>
                                <div class="deletes" v-if="sum(26)">
                                    <a @click="deletesClick(v.id)" href="javascript:;">
                                        <img src="images/deletes.png">
                                    </a>
                                    <span>删除</span>
                                </div>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
                <!--回访页面弹窗开始-->
                <div class="visitBox hidden">
                    <div class="layerbody">
                        <div class="addbtn">
                            <a @click="addvisitClick()" href="javascript:;">新增</a>
                        </div>
                        <div class="visitList">
                            <ul>
                                <li>
                                    <ol><input @click="deleteCheckAll()" class="checkboxAll" id="deleteCheckAll"
                                               type="checkbox"> 全选
                                    </ol>
                                    <ol class="useName">客户名称</ol>
                                    <ol>客户状态</ol>
                                    <ol>提醒日期</ol>
                                    <ol>操作</ol>
                                </li>
                                <li @dblclick="editorHfClick(v.id)" v-for="(v,index) in trackeDataList">
                                    <ol><input class="selectCheck" type="checkbox"></ol>
                                    <ol class="useName">{{v.title}}</ol>
                                    <ol>{{v.status == 1 ? '有效客户' : '无效客户' }}</ol>
                                    <ol>{{v.remindtime}}</ol>
                                    <ol>
                                        <div class="editor">
                                            <a @click="editorHfClick(v.id)" href="javascript:;">
                                                <img src="images/editor.png">
                                            </a>
                                            <span>编辑</span>
                                        </div>
                                        <div class="deletes">
                                            <a @click="visitdeletesClick(v.id)" href="javascript:;">
                                                <img src="images/deletes.png">
                                            </a>
                                            <span>删除</span>
                                        </div>
                                    </ol>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
                <!--回访页面弹窗结束-->

                <!--回访弹窗里面的新增回访记录(二级弹窗)-->
                <div class="visitboxDouble hidden">
                    <div class="layerbody">
                        <label>
                            <span>客户状态:</span>
                            <div class="layui-input-block">
                                <select class="industry" id="status" lay-filter="batch"
                                        lay-search="required" lay-verify="required" name="resetTc">
                                    <option class="promptColor" value="">请选择客户状态</option>
                                    <option value="1">有效</option>
                                    <option value="0">无效</option>
                                </select>
                            </div>
                        </label>
                        <label>
                            <span>提醒日期:</span>
                            <div class="layui-input-inline">
                                <input class="layui-input" id="remindtime" name="resetval" placeholder="yyyy-MM-dd"
                                       type="text"/>
                            </div>
                        </label>
                        <label>
                            <span>跟进日期:</span>
                            <div class="layui-input-inline">
                                <input class="layui-input" id="tracktime" name="resetval" placeholder="yyyy-MM-dd"
                                       type="text"/>
                            </div>
                        </label>
                        <div class="address">
                            <label>
                                <span>回访记录:</span>
                                <textarea class="contents" id="content1" name="resetTc" placeholder="回访记录" resize=""
                                          rows="4"></textarea>
                            </label>
                        </div>
                    </div>
                    <button @click="visitsureBtn()" class="surebtn" type="submit">确认</button>
                    <button @click="addresetBtn()" class="resetbtn" type="submit">重置</button>
                </div>
                <!--回访弹窗里面的新增回访记录(二级弹窗)-->

                <!---------------------------分页start----------------------------->
                <div class="pageFen" v-if="totalNum>1">
                    <ul>
                        <li>
                            <a @click="setPage(curNum-1)" class="pageLink" href="#">上一页</a>
                        </li>
                        <li v-for="n in totalNum">
                            <a class="pageLink curNum" v-if="n == curNum" v-text="n"></a>
                            <a @click="setPage(n)" class="pageLink" href="javascript:;" v-else v-text="n"></a>
                        </li>
                        <li><a @click="setPage(curNum+1)" class="pageLink" href="#">下一页</a></li>
                    </ul>
                </div>
                <!---------------------------分页end-------------------------------->
            </div>
        </section>
    </div>
</div>
<script src="/web/js/vue.js"></script>
<script src="/web/js/jquery-1.10.0.min.js"></script>
<script src="/web/layui/layui.js"></script>
<script src="/web/js/transform.js"></script>
<script>
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        //录入时间
        laydate.render({
            elem: '#date1', //指定元素
            type: "date", // 组件的类型：year,month,time···
            format: 'yyyy-MM-dd'// 设置显示格式
        });
        //提醒日期
        laydate.render({
            elem: '#remindtime', //指定元素
            type: "date", // 组件的类型：year,month,time···
            format: 'yyyy-MM-dd'// 设置显示格式
        });
        //最后跟进时间
        laydate.render({
            elem: '#date2', //指定元素
            type: "date", // 组件的类型：year,month,time···
            format: 'yyyy-MM-dd'// 设置显示格式
        });
        //最后跟进时间
        laydate.render({
            elem: '#endtrack', //指定元素
            type: "date", // 组件的类型：year,month,time···
            format: 'yyyy-MM-dd'// 设置显示格式
        });
        //跟进时间
        laydate.render({
            elem: '#tracktime', //指定元素
            type: "date", // 组件的类型：year,month,time···
            format: 'yyyy-MM-dd'// 设置显示格式
        });
        //弹窗的咨询日期
        laydate.render({
            elem: '#date3', //指定元素
            type: "date", // 组件的类型：year,month,time···
            format: 'yyyy-MM-dd'// 设置显示格式
        });
    });
</script>
<script>
    AppData = new Vue({
        el: '#app',
        data: {
            tableData: {},
            categoryIndex: 0,
            show: false,
            tableDataList: {},
            trackeDataList: {},
            map: {},
            ajaxData: [],
            totalNum: 0, //总页数
            listRows: 8, //每页数量
            curNum: 1, //当前页码
            departmentList: {},
            dataList: {},
            provinceid: 0,
            cityid: 0,
            status:1,
            typeid: 0,
            categoryid: 0,
            fromid: 0,
            industryid: 0,
            userid: 0,
            addoredit: 0,
            archivesid: 0,
            characterid: 2
        },
        mounted() {
            $("#head").load("header.html");
            $("#right_h").load("right.html");
            this.getIndexData();
        },
        methods: {
            verification(data) {
                if (data.status == 2) {
                    layer.msg(data.message, {icon: 2, time: 1000}, function () {
                        window.location.href = "login.html";
                    });
                }
            },
            search(e) {
                var that = this;
                var keywords = e.target.value;
                this.map.title = keywords;
                this.getIndexData();
            },
            searchbtnClick() {
                //获取所有搜索关键值
                var map = {
                    title: $('#searchtitle').val(),
                    typeid: $('#searchtype').val(),
                    status: $('#searchstatus').val(),
                    industryid: $('#searchindustry').val(),
                    provinceid: $('#searchprovince').val(),
                    categoryid: $('#categoryid').val(),
                    tel: $('#searchtel').val(),
                    fromid: $('#searchfrom').val(),
                    userid: $('#searchuser').val()
                };
                this.map = map;
                this.getIndexData();
                console.log(this.map);
            },
            adSearchbtnClick() {
                $('.searchBox').slideToggle();
                $('.search').toggle();
            },
            resetbtnClick() {
                this.map = {};
                $('input[name="resetval"]').val('');
                $('select[name="resetval"]').val('');
                this.getIndexData();
            },
            addresetBtn() {
                $('input[name="resetTc"]').val('');
                $('select[name="resetTc"]').val('');
                $('textarea[name="resetTc"]').val('');
                this.provinceid = 0;
                this.cityid = 0;
                this.typeid = 0;
                this.categoryid = 0;
                this.fromid = 0;
                this.industryid = 0;
                this.userid = 0;
            },

            //----------------------------------------------------------------------------------------------------------------------------------------------------------
            getIndexData() {
                $.ajax({
                    type: "GET",
                    dataType: "json",
                    url: '/archives',
                    data: {'listRows': this.listRows, 'page': this.curNum, map: this.map},
                    success: function (data) {
                        AppData.verification(data);
                        AppData.totalNum = data.list.last_page;  //获取总的页面数
                        AppData.dataList = data.userInfo.jurisdiction; //所有的权限
                        AppData.ajaxData = data;
                        let dataS = data.userInfo.jurisdiction;//后台初始数据
                        var dataArr = [];
                        for (let i in dataS) {
                            dataArr.push(dataS[i]); //属性
                        }
                        /*调用封装的改变数据结构方法*/
                        let tableData = setTreeData(dataArr);
                        let tableDataObj = {...tableData};//把转换后的数组通过扩展运算符改成对象便于遍历
                        AppData.tableData = tableDataObj;
                        //表格中数据的渲染
                        let tableList = {...data.list.data};
                        // //转换时间戳为具体的年月日
                        // let dataObj = data.list.data;
                        // for (let i in dataObj) {
                        //     var dataObj1 = dataObj[i].lasttime;
                        //     var date = new Date(dataObj1 * 1000);
                        //     dataObj[i].lasttime = date.getFullYear() + '-' + (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-' + date.getDate() + ' ';
                        //     var dataObj1 = dataObj[i].createtime;
                        //     var date = new Date(dataObj1 * 1000);
                        //     dataObj[i].createtime = date.getFullYear() + '-' + (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-' + date.getDate() + ' ';
                        // }
                        AppData.tableDataList = tableList;
                        console.log(AppData.tableDataList);
                    },
                    error: function (msg) {
                    }
                });
            },
            setPage(num) {
                //页码小于等于1
                if (num < 1) {
                    num = 1;
                }
                //页码大于总页数
                if (num > this.totalNum) {
                    num = this.totalNum;
                }
                //页码赋给当前页
                this.curNum = num;
                this.getIndexData();
            },
            sum(sumid) {//验证列表里的修改删除是否要显示(根据对应的id)
                for (i in this.dataList) {
                    if (sumid == this.dataList[i].id) {
                        return true;
                    }
                }
                return false;
            },
            addbtnClick() {
                this.addresetBtn();
                this.addoredit = 0;
                layeraddoredit = layer.open({
                    type: 1,
                    title: '基本设置',
                    maxmin: true,
                    resize: true,
                    shadeClose: false, //点击遮罩关闭层
                    area: ['900px', '750px'],
                    content: $('.consulting'),
                    success: function () {
                        $.ajax({
                            type: "GET",
                            dataType: "json",
                            url: '/archives/create',
                            data: {},
                            success: function (data) {
                                AppData.verification(data);
                                AppData.ajaxData = data;
                            },
                            error: function (msg) {
                                console.log(msg);
                            }
                        });
                    },
                    end: function () { //解决弹窗关闭以后,弹窗内容还出现在下方的问题
                        $('.consulting').hide();
                    }
                })
            },
            provincechange(e) {
                id = event.target.value;
                $.ajax({
                    type: "GET",
                    dataType: "json",
                    url: '/clue/' + id + '/edit',
                    data: {},
                    success: function (data) {
                        AppData.verification(data);
                        AppData.ajaxData.city = data.citys;
                    },
                    error: function (msg) {
                        console.log(msg);
                    }
                });
            },
            editorClick(edid) {
                this.addoredit = edid;
                layeraddoredit = layer.open({
                    type: 1,
                    title: '编辑菜单',
                    maxmin: true,
                    resize: true,
                    shadeClose: false, //点击遮罩关闭层
                    area: ['900px', '750px'],
                    content: $('.consulting'),
                    success: function () {
                        $.ajax({
                            type: "GET",
                            dataType: "json",
                            url: '/archives/' + edid,
                            data: {'id': edid},
                            success: function (data) {
                                AppData.verification(data);
                                AppData.ajaxData = data;
                                //编辑框赋值
                                // var date = new Date(data.info.firsttime * 1000);
                                AppData.provinceid = data.info.provinceid;
                                AppData.cityid = data.info.cityid;
                                AppData.typeid = data.info.typeid;
                                AppData.categoryid = data.info.categoryid;
                                AppData.fromid = data.info.fromid;
                                AppData.industryid = data.info.industryid;
                                AppData.userid = data.info.userid;
                                AppData.status = data.info.status;
                                $('#title').val(data.info.title);
                                $('#link').val(data.info.link);
                                $('#contacts').val(data.info.contacts);
                                $('#tel').val(data.info.tel);
                                $('#address').val(data.info.address);
                                $('#date3').val(data.info.firsttime);
                                $('#content').val(data.info.content);
                            },
                            error: function (msg) {
                                console.log(msg);
                            }
                        });
                    },
                    end: function () { //解决弹窗关闭以后,弹窗内容还出现在下方的问题
                        $('.consulting').hide();
                    }
                })
            },
            addeditsureBtn(){
                //获取添加值
                var data = {
                    title: $('#title').val(),
                    link: $('#link').val(),
                    contacts: $('#contacts').val(),
                    tel: $('#tel').val(),
                    provinceid: $('#provinceid').val(),
                    cityid: $('#cityid').val(),
                    address: $('#address').val(),
                    typeid: $('#typeid').val(),
                    categoryid: $('#categoryid').val(),
                    fromid: $('#fromid').val(),
                    industryid: $('#industryid').val(),
                    firsttime: $('#date3').val(),
                    userid: $('#userid').val(),
                    content: $('#content').val(),
                    status: this.status
                };
                if (this.addoredit) {
                    $.ajax({
                        type: "PUT",
                        dataType: "json",
                        url: '/archives/' + this.addoredit,
                        data: data,
                        success: function (data) {
                            AppData.verification(data);
                            if (data.status == 1) {
                                layer.msg(data.message, {icon: 1, time: 1000}, function () {
                                    AppData.getIndexData();
                                    layer.close(layeraddoredit);
                                });
                            } else {
                                layer.msg(data.message, {icon: 2, time: 1000});
                            }
                        },
                        error: function (msg) {
                            console.log(msg);
                        }
                    });
                } else {
                    $.ajax({
                        type: "POST",
                        dataType: "json",
                        url: '/archives',
                        data: data,
                        success: function (data) {
                            AppData.verification(data);
                            if (data.status == 1) {
                                layer.msg(data.message, {icon: 1, time: 1000}, function () {
                                    AppData.getIndexData();
                                    layer.close(layeraddoredit);
                                });
                            } else {
                                layer.msg(data.message, {icon: 2, time: 1000});
                            }
                        },
                        error: function (msg) {
                            console.log(msg);
                        }
                    });
                }
            },
            deleteCheckAll() {
                let checkBoxs = AppData.tableDataList;
                if ($('#deleteCheckAll').is(":checked")) {
                    for (let j in checkBoxs) {
                        $('#listcheck' + checkBoxs[j].id).prop('checked', true);
                    }
                } else {
                    for (let j in checkBoxs) {
                        $('#listcheck' + checkBoxs[j].id).prop('checked', false);
                    }
                }
            },
            deletesClick(deleteid) {
                layui.use('layer', function () {
                    layer.confirm('确认要删除吗？', {
                        btn: ['确定', '取消']//按钮
                    }, function () {
                        let ids = [];
                        if (deleteid) {
                            //单个删除
                            ids.push(deleteid);
                        } else {
                            //全部删除
                            let checkBoxs = AppData.tableDataList;
                            for (let i in checkBoxs) {
                                if ($('#listcheck' + checkBoxs[i].id).is(":checked")) {
                                    ids.push(checkBoxs[i].id);
                                }
                            }
                        }
                        if (ids.length == 0) {
                            layer.msg('请选择你要删除的选项');
                            return false;
                        }
                        $.ajax({
                            type: "DELETE",
                            dataType: "json",
                            url: '/archives/0',
                            data: {'ids': ids},
                            success: function (data) {
                                AppData.verification(data);
                                if (data.status == 1) {
                                    layer.msg(data.message, {icon: 1, time: 1000}, function () {
                                        //重新加载列表
                                        AppData.getIndexData();
                                    });
                                } else {
                                    layer.msg(data.message, {icon: 2, time: 1000});
                                }
                            },
                            error: function (msg) {
                            }
                        });
                    });
                });
            },
            visitClick(id) {//回访弹窗
                this.archivesid = id;
                visitbox = layer.open({
                    type: 1,
                    title: '回访',
                    maxmin: true,
                    resize: true,
                    shadeClose: false, //点击遮罩关闭层
                    id: 'layer01',
                    area: ['850px', '650px'],
                    content: $('.visitBox'),
                    success: function () {
                        AppData.gettrackDataList();
                    },
                    end: function () { //解决弹窗关闭以后,弹窗内容还出现在下方的问题
                        $('.visitBox').hide();
                    }
                });
            },
            gettrackDataList() {//回访弹窗加载数据
                $.ajax({
                    type: "GET",
                    dataType: "json",
                    url: '/track',
                    data: {listRows: AppData.listRows, page: AppData.curNum, archivesid: AppData.archivesid},
                    success: function (data) {
                        AppData.verification(data);
                        AppData.trackeDataList = data.list.data;
                        console.log(data);
                    },
                    error: function (msg) {
                    }
                });
            },
            addvisitClick() {//回访弹窗里面的二级弹窗
                this.addoredit = 0;
                layervisit = visitboxdouble = parent.layer.open({
                    type: 1,
                    title: '回访',
                    maxmin: true,
                    resize: true,
                    id: 'layer02',
                    shadeClose: false, //点击遮罩关闭层
                    area: ['800px', '500px'],
                    content: $('.visitboxDouble'),
                    success: function () {
                    },
                    end: function () { //解决弹窗关闭以后,弹窗内容还出现在下方的问题
                        $('.visitboxDouble').hide();
                    }
                });
            },
            editorHfClick(id) {//回访弹窗里面的二级弹窗
                this.addoredit = id;
                layervisit = visitboxdouble = parent.layer.open({
                    type: 1,
                    title: '回访',
                    maxmin: true,
                    resize: true,
                    id: 'layer03',
                    shadeClose: false, //点击遮罩关闭层
                    area: ['800px', '500px'],
                    content: $('.visitboxDouble'),
                    success: function () {
                        $.ajax({
                            type: "GET",
                            dataType: "json",
                            url: '/track/' + id,
                            data: {},
                            success: function (data) {
                                AppData.verification(data);
                                //编辑框赋值
                                $('#status').val(data.info.status);
                                $('#remindtime').val(data.info.remindtime);
                                $('#tracktime').val(data.info.tracktime);
                                $('#content1').val(data.info.content);
                            },
                            error: function (msg) {
                            }
                        });
                    },
                    end: function () { //解决弹窗关闭以后,弹窗内容还出现在下方的问题
                        $('.visitboxDouble').hide();
                    }
                });
            },
            visitsureBtn() {
                //获取添加值
                var data = {
                    status: $('#status').val(),
                    remindtime: $('#remindtime').val(),
                    tracktime: $('#tracktime').val(),
                    content: $('#content1').val(),
                    archivestype: 1,
                    archivesid: this.archivesid
                };
                if (this.addoredit) {
                    $.ajax({
                        type: "PUT",
                        dataType: "json",
                        url: '/track/' + this.addoredit,
                        data: data,
                        success: function (data) {
                            AppData.verification(data);
                            if (data.status == 1) {
                                layer.msg(data.message, {icon: 1, time: 1000}, function () {
                                    //保存完成,重新加载窗口列表
                                    AppData.gettrackDataList();
                                    layer.close(layervisit);
                                });
                            } else {
                                layer.msg(data.message, {icon: 2, time: 1000});
                            }
                        },
                        error: function (msg) {
                            console.log(msg);
                        }
                    });
                } else {
                    $.ajax({
                        type: "POST",
                        dataType: "json",
                        url: '/track',
                        data: data,
                        success: function (data) {
                            AppData.verification(data);
                            if (data.status == 1) {
                                layer.msg(data.message, {icon: 1, time: 1000}, function () {
                                    //新增完成,重新加载窗口列表
                                    AppData.gettrackDataList();
                                    layer.close(layervisit);
                                });
                            } else {
                                layer.msg(data.message, {icon: 2, time: 1000});
                            }
                        },
                        error: function (msg) {
                            console.log(msg);
                        }
                    });
                }
            },
            visitdeletesClick(deleteid) {
                layui.use('layer', function () {
                    layer.confirm('确认要删除吗？', {
                        btn: ['确定', '取消']//按钮
                    }, function () {
                        let ids = [];
                        //单个删除
                        ids.push(deleteid);
                        if (ids.length == 0) {
                            layer.msg('请选择你要删除的选项');
                            return false;
                        }
                        $.ajax({
                            type: "DELETE",
                            dataType: "json",
                            url: '/track/0',
                            data: {'ids': ids},
                            success: function (data) {
                                AppData.verification(data);
                                if (data.status == 1) {
                                    layer.msg(data.message, {icon: 1, time: 1000}, function () {
                                        //重新加载列表
                                        AppData.gettrackDataList();
                                    });
                                } else {
                                    layer.msg(data.message, {icon: 2, time: 1000});
                                }
                            },
                            error: function (msg) {
                            }
                        });
                    });
                });
            },
            viewClick(id) {
                localStorage.trackid = id;
                window.location.href = "/web/customer-details.html";
            }
        }
    })
</script>
</body>
</html>
